package com.ruixinzheng.mvpdemo.presenter;

import com.ruixinzheng.mvpdemo.model.MainRepo;
import com.ruixinzheng.mvpdemo.view.MainBaseView;

public class MainBasePresenterImpl implements MainBasePresenter {
    private MainBaseView mMainView;
	private MainRepo mRepo;

    @Override
    public void attachView(MainBaseView v) {
        mMainView = v;
		mRepo = MainRepo.getInstance();
    }

    @Override
    public void detachView() {
        mMainView = null;
    }

    @Override
    public void increaseCount() {
        int count = mRepo.increaseCount();
        if (mMainView != null) {
            mMainView.updateText(count);
        }
    }

    @Override
    public int getCount() {
        return mRepo.getCount();
    }
}
